import request from '@/utils/request'

//常量
const api_name = '/admin/system/sysRole/'

export default {
    //列表
    getPageList(page,limit,searchObj) {
        return request({
            url: `/admin/system/sysRole/find/${page}/${limit}`,
            method: 'post',
            data: searchObj
        })
    },
    //删除
    removeId(id) {
        return request({
            url: `/admin/system/sysRole/deleteById/${id}`,
            method: 'delete'
        })
    },
    //添加
    saveRole(role) {
        return request({
            url: `/admin/system/sysRole/save`,
            method: 'post',
            data: sysRole
        })
    },
    //根据id查询
    getRoleId(id) {
        return request({
            url: `/admin/system/sysRole/getRoleInfoById/${id}`,
            method: 'get'
        })
    },
    //修改的方法
    update(role) {
        return request({
            url: `/admin/system/sysRole/update`,
            method: 'post',
            data: role
        })
    },
    //批量删除
    batchRemove(idList) {
        return request({
            url: `/admin/system/sysRole/batchRemove`,
            method: 'delete',
            data: idList
        })
    },
    //根据用户id查询用户已分配的角色
    getRolesByUserId(userId) {
        return request({
            url: `/admin/system/sysRole/toAssign/${userId}`,
            method: 'get'
            })
    },
    //分配角色
    assignRoles(assginRoleVo) {
        return request({
            url: `/admin/system/sysRole/assignRole`,
            method: 'post',
            data: assginRoleVo
            })
    }
}